package com.syh.core.ddd.infrastructure.event;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.LinkedHashMap;


/**
 *  构建event事件消息
 */
@Data
public class EventMthod {

	private String eventServiceName;
	private String eventMethodName;
	private LinkedHashMap<String,Object> eventMethodParam;

	/**
	 * 构建自定义异步调用消息主体
	 * @return 消息主体
	 */
	public String toJson(){
		JSONObject json=new JSONObject();
		json.put("eventServiceName",eventServiceName);
		json.put("eventMethodName",eventMethodName);
		json.put("eventMethodParam",eventMethodParam);
		return json.toJSONString();
	}

	/**
	 *  供应商商品出库异步调用
	 * @param paramMap 商品方法映射参数
	 * @return 异步消息主体
	 */
	public static String supplierGoodsOut(LinkedHashMap paramMap){
		JSONObject json=new JSONObject();
		json.put("eventServiceName",EventName.MNS_SUPPLIER_GOODS_OUT);
		json.put("eventMethodName",EventName.MNS_SUPPLIER_GOODS_OUT_METHOD);
		json.put("eventMethodParam",paramMap);
		return json.toJSONString();
	}

	public static String testRe(LinkedHashMap paramMap){
		JSONObject json=new JSONObject();
		json.put("eventServiceName",EventName.MNS_SUPPLIER_GOODS_OUT);
		json.put("eventMethodName","testRe");
		json.put("eventMethodParam",paramMap);
		return json.toJSONString();
	}

}
